package com.hh.base.util;

/**
 * Created by liuhanhui on 2017/10/27.
 */
public class StringUtil {
    public static char toUpperCase(char chars) {
        if (97 <= chars && chars <= 122) {
            chars ^= 32;
        }
        return chars;
    }

    public static String toUpperCase4Index(String string) {
        char[] methodName = string.toCharArray();
        methodName[0] = toUpperCase(methodName[0]);
        return String.valueOf(methodName);
    }

    /**
     * 取出下划线且将下划线之后的首字母大写
     * */
    public static String formatArgsName(String name) {
        String[] names = name.split("_");
        StringBuilder sb = new StringBuilder(names[0]);
        for (int i = 1; i < names.length; i++) {
            sb.append(StringUtil.toUpperCase4Index(names[i]));
        }
        return sb.toString();
    }
}
